import React from "react";
import {
	GestureResponderEvent,
	StyleSheet,
	Text,
	TouchableOpacity,
	View,
} from "react-native";

export default function TextButton(props: {
	buttonText: string;
	backgroundColor: string;
	textColor?: string;
	onPress: (event: GestureResponderEvent) => void;
	disabled?: boolean; // 按钮是否禁用
}) {
	const {
		buttonText,
		backgroundColor,
		textColor = "#000",
		onPress,
		disabled = false,
	} = props;

	return (
		<TouchableOpacity onPress={onPress}>
			<View
				style={[
					disabled
						? { backgroundColor: "#dfdfdf" }
						: { backgroundColor },
					styles.buttonContainer,
				]}
			>
				<Text
					style={[
						disabled ? { color: "#aaaaaa" } : { color: textColor },
						styles.buttonText,
					]}
				>
					{buttonText}
				</Text>
			</View>
		</TouchableOpacity>
	);
}
const styles = StyleSheet.create({
	buttonContainer: {
		paddingVertical: 12,
		borderRadius: 12,
	},
	buttonText: {
		textAlign: "center",
		fontSize: 14,
		fontWeight: "600",
	},
});
